﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pad
{
    [Serializable]
    class Pad
    {

        public List<Note> PAD { get; set; }

        public Pad(params Note[] n)
        {
            PAD = n.ToList();
        }

        public void Add(Note n)
        { PAD.Add(n); }
        public void Remove(Note n)
        { PAD.Remove(n); }

        public List<Note> DSearchName(string firstName, string lastName = "", int birthDay = 0, string phone = "")
        {
            IEnumerable<Note> linq = PAD.AsEnumerable();
            if (firstName != "") linq = from s in linq where s.FirstName.Contains(firstName) select s;
            if (lastName != "") linq = from s in linq where s.LastName.Contains(lastName) select s;
            if (birthDay != 0) linq = from s in linq where s.BirthDay == birthDay select s;
            if (phone != "") linq = from s in linq where s.Phone.Contains(phone) select s;

            return
                linq.ToList();
        }
    }
}
